#!/usr/bin/env python
#coding=utf-8

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkbssopenapi.request.v20171214.QueryAccountBalanceRequest import QueryAccountBalanceRequest
import json

class ali_bill_QueryAccountBalance:

    def __init__(self,accessKeyid,accessSecret):
        self.accessKeyid = accessKeyid
        self.accessSecret = accessSecret
 
    #### 获取阿里云账户余额
    def QueryAccountBalance(self):
        client = AcsClient(self.accessKeyid, self.accessSecret, 'cn-hangzhou')

        request = QueryAccountBalanceRequest()
        request.set_accept_format('json')

        response = client.do_action_with_exception(request)
        # python2:  print(response) 
        result = str(response, encoding='utf-8')
        print (json.loads(result)['Data']['AvailableCashAmount'])

accessName = ali_bill_QueryAccountBalance('','')
accessName.QueryAccountBalance()
